package com.cookie.lib_base.base

import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import androidx.viewpager.widget.ViewPager

/**
 *   文件名:    BasePagerAdapter
 *   创建者:    cookie
 *   创建时间:   2020/10/20 10:42
 *   描述:      TODO
 */
class BasePagerAdapter(private val mList :List<View>):PagerAdapter() {

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`
    }

    override fun getCount(): Int {
        return mList.size
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        (container as ViewPager).addView(mList[position])
        return mList[position]
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        (container as ViewPager).removeView(mList[position])
    }
}